package com.gsafety.wellsfort.config;

import com.gsafety.wellsfort.common.util.DelayQueueProvider;
import com.gsafety.wellsfort.service.task.Task;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

/**
 * @author tangjiawei
 * @date 2020/5/24
 */
@Slf4j
@Component
public class AutoExecuteHandler implements CommandLineRunner {
    @Override
    public void run(String... args) throws Exception {
        new Thread(new Runnable() {
            @Override
            public void run() {
                log.info("启动线程,执行延迟队列任务..");
                Task task = DelayQueueProvider.get();
                if (task != null) {
                    task.doWork();
                }
            }
        }).start();
    }
}
